namespace Resharper.Abstractions.CodeDom.Statements.DeclarationStatements
{
  using System.Collections.Generic;
  using JetBrains.Annotations;
  using JetBrains.ReSharper.Psi.CSharp.Tree;
  using Resharper.Abstractions.CodeDom.Statements.ForStatements;

  /// <summary>Defines the <see cref="ForStatement"/> class.</summary>
  public class DeclarationStatement : Statement
  {
    #region Constructors and Destructors

    /// <summary>Initializes a new instance of the <see cref="ForStatement"/> class.</summary>
    /// <param name="statement">The expression.</param>
    internal DeclarationStatement([NotNull] IDeclarationStatement statement) : base(statement)
    {
    }

    #endregion

    #region Properties

    /// <summary>
    /// Gets the expression.
    /// </summary>
    public IEnumerable<VariableDeclaration> VariableDeclarations
    {
      get
      {
        foreach (var localVariableDeclaration in this.InternalDeclarationStatement.VariableDeclarations)
        {
          yield return new VariableDeclaration(localVariableDeclaration);
        }
      }
    }

    /// <summary>
    /// Gets the internal declaration statement.
    /// </summary>
    [NotNull]
    internal IDeclarationStatement InternalDeclarationStatement
    {
      get
      {
        return (IDeclarationStatement)this.InternalStatement;
      }
    }

    #endregion
  }
}